home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Mousetools / FollowMouse / FollowMouse.p < prev    next >
Text File  |  1996-09-26  |  20KB  |  609 lines

  1. {
  2.  FollowMouse.p Copyright © Kamran Karimi. Shows a pair of small blinking
  3.  eyes. Compiled using  Maxon KickPascal on an A500
  4.  
  5. Program FollowMouse;
  6.  
  7. uses Intuition;
  8.  
  9.  
  10. Type
  11.   Plane = Array[1..39] of Word;     { 3*13 = 39;place for the images }
  12.  
  13.   label EndIt;
  14.  
  15. Var
  16.   bool: Boolean;
  17.   x1,y1,Old,R,count,CurCoOrd,CurImage,SameImage,PrevCoOrd :integer;
  18.   Sec1,Mic1,Sec2,Mic2 : Long;
  19.   x,add,Ang,Mx,My :real;
  20.   Wind :NewWindow;
  21.   Rast :^RastPort;
  22.   Win :^Window;
  23.   Mes1,Mes2 :^IntuiMessage;
  24.   PRG,Name :IntuiText;
  25.   ImSquaint,ImStraight,ImDown,ImUp,ImLeft,ImRight,ImRU,ImRD,ImLU,
  26.                                    ImLD,ImF1,ImF2,ImF3,ImF4 :Image;
  27.   Down,Up,Left,Right,RU,RD,LU,LD,Squaint,Straight,F1,F2,F3,F4 :^Plane;
  28.  
  29. Procedure Initialize;
  30.  begin
  31.  
  32.   {initializing the images: }
  33.  
  34.  
  35.   Straight^ :=Plane(
  36.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  37.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  38.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  39.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  40.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  41.   %0000111111000011 ,%1111000000001111 ,%1100001111110000,
  42.   %0000111110000001 ,%1111000000001111 ,%1000000111110000,
  43.   %0000111111000011 ,%1111000000001111 ,%1100001111110000,
  44.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  45.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  46.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  47.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  48.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  49.  
  50.   Down^ :=Plane(
  51.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  52.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  53.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  54.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  55.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  56.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  57.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  58.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  59.   %0000011111000011 ,%1110000000000111 ,%1100001111100000,
  60.   %0000001110000001 ,%1100000000000011 ,%1000000111000000,
  61.   %0000000111000011 ,%1000000000000001 ,%1100001110000000,
  62.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  63.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  64.  
  65.   Up^ := Plane(
  66.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  67.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  68.   %0000000111000011 ,%1000000000000001 ,%1100001110000000,
  69.   %0000001110000001 ,%1100000000000011 ,%1000000111000000,
  70.   %0000011111000011 ,%1110000000000111 ,%1100001111100000,
  71.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  72.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  73.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  74.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  75.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  76.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  77.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  78.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  79.  
  80.   Left^ :=Plane(
  81.   %0000000000000000 ,%0000000000000000,%0000000000000000,
  82.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  83.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  84.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  85.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  86.   %0000110000111111 ,%1111000000001100 ,%0011111111110000,
  87.   %0000100000011111 ,%1111000000001000 ,%0001111111110000,
  88.   %0000110000111111 ,%1111000000001100 ,%0011111111110000,
  89.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  90.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  91.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  92.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  93.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  94.  
  95.   Right^ :=Plane(
  96.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  97.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  98.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  99.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  100.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  101.   %0000111111111100 ,%0011000000001111 ,%1111110000110000,
  102.   %0000111111111000 ,%0001000000001111 ,%1111100000010000,
  103.   %0000111111111100 ,%0011000000001111 ,%1111110000110000,
  104.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  105.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  106.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  107.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  108.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  109.  
  110.   LD^ :=Plane(
  111.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  112.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  113.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  114.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  115.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  116.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  117.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  118.   %0000111000011111 ,%1111000000001110 ,%0001111111110000,
  119.   %0000010000001111 ,%1110000000000100 ,%0000111111100000,
  120.   %0000001000011111 ,%1100000000000010 ,%0001111111000000,
  121.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  122.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  123.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  124.  
  125.   RD^ :=Plane(
  126.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  127.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  128.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  129.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  130.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  131.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  132.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  133.   %0000111111111000 ,%0111000000001111 ,%1111100001110000,
  134.   %0000011111110000 ,%0010000000000111 ,%1111000000100000,
  135.   %0000001111111000 ,%0100000000000011 ,%1111100001000000,
  136.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  137.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  138.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  139.  
  140.   RU^ :=Plane(
  141.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  142.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  143.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  144.   %0000001111111000 ,%0100000000000011 ,%1111100001000000,
  145.   %0000011111110000 ,%0010000000000111 ,%1111000000100000,
  146.   %0000111111111000 ,%0111000000001111 ,%1111100001110000,
  147.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  148.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  149.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  150.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  151.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  152.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  153.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  154.  
  155.   LU^ :=Plane(
  156.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  157.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  158.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  159.   %0000001000011111 ,%1100000000000010 ,%0001111111000000,
  160.   %0000010000001111 ,%1110000000000100 ,%0000111111100000,
  161.   %0000111000011111 ,%1111000000001110 ,%0001111111110000,
  162.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  163.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  164.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  165.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  166.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  167.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  168.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  169.  
  170.   Squaint^ :=Plane(
  171.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  172.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  173.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  174.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  175.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  176.   %0000111111111100 ,%0011000000000100 ,%0011111111110000,
  177.   %0000111111111000 ,%0001000000001000 ,%0001111111110000,
  178.   %0000111111111100 ,%0011000000001100 ,%0011111111110000,
  179.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  180.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  181.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  182.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  183.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  184.  
  185.  
  186.  F1^ :=Plane(
  187.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  188.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  189.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  190.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  191.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  192.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  193.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  194.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  195.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  196.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  197.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  198.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  199.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  200.  
  201.  F2^ :=Plane(
  202.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  203.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  204.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  205.   %0000001110000001 ,%1100000000000011 ,%1000000111000000,
  206.   %0000010001111110 ,%0010000000000100 ,%0111111000100000,
  207.   %0000101111111111 ,%1101000000001011 ,%1111111111010000,
  208.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  209.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  210.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  211.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  212.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  213.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  214.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  215.  
  216.  F3^ :=Plane(
  217.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  218.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  219.   %0000000011111111 ,%1000000000000001 ,%1111111110000000,
  220.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  221.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  222.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  223.   %0000100000000000 ,%0001000000001000 ,%0000000000010000,
  224.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  225.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  226.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  227.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  228.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  229.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  230.  
  231.  F4^ :=Plane(
  232.   %0000000000000000 ,%0000000000000000 ,%0000000000000000,
  233.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  234.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  235.   %0000001111111111 ,%1100000000000011 ,%1111111111000000,
  236.   %0000011111111111 ,%1110000000000111 ,%1111111111100000,
  237.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  238.   %0000111111111111 ,%1111000000001111 ,%1111111111110000,
  239.   %0000101111111111 ,%1101000000001011 ,%1111111111010000,
  240.   %0000010001111110 ,%0010000000000100 ,%0111111000100000,
  241.   %0000001110000001 ,%1100000000000011 ,%1000000111000000,
  242.   %0000000111111111 ,%1000000000000001 ,%1111111110000000,
  243.   %0000000000111100 ,%0000000000000000 ,%0011110000000000,
  244.   %0000000000000000 ,%0000000000000000 ,%0000000000000000 );
  245.  
  246.  
  247.   { Image-Structure }
  248.   ImStraight:=Image(1,1,
  249.              48,      { width }
  250.              13,      { hight }
  251.              1,       { one Plane }
  252.              Straight,     { data }
  253.              1,0,
  254.              Nil);    { no further Images }
  255.  
  256.   ImDown:=Image(1,1,
  257.              48,     
  258.              13,     
  259.              1,      
  260.              Down,   
  261.              1,0,
  262.              Nil);   
  263.  
  264.   ImUp:=Image(1,1,
  265.              48,
  266.              13,
  267.              1,
  268.              Up,
  269.              1,0,
  270.              Nil);
  271.  
  272.   ImRight:=Image(1,1,
  273.              48,
  274.              13,
  275.              1,
  276.              Right,
  277.              1,0,
  278.              Nil);
  279.  
  280.   ImLeft:=Image(1,1,
  281.              48,
  282.              13,
  283.              1,
  284.              Left,
  285.              1,0,
  286.              Nil);
  287.  
  288.   ImRU:=Image(1,1,
  289.              48,
  290.              13,
  291.              1,
  292.              RU,
  293.              1,0,
  294.              Nil);
  295.  
  296.   ImRD:=Image(1,1,
  297.              48,
  298.              13,
  299.              1,
  300.              RD,
  301.              1,0,
  302.              Nil);
  303.  
  304.   ImLU:=Image(1,1,
  305.              48,
  306.              13,
  307.              1,
  308.              LU,
  309.              1,0,
  310.              Nil);
  311.  
  312.   ImLD:=Image(1,1,
  313.              48,
  314.              13,
  315.              1,
  316.              LD,
  317.              1,0,
  318.              Nil);
  319.  
  320.   ImSquaint:=Image(1,1,
  321.              48,
  322.              13,
  323.              1,
  324.              Squaint,
  325.              1,0,
  326.              Nil);
  327.  
  328.   ImF1:=Image(1,1,
  329.              48,
  330.              13,
  331.              1,
  332.              F1,
  333.              1,0,
  334.              Nil);
  335.  
  336.   ImF2:=Image(1,1,
  337.              48,
  338.              13,
  339.              1,
  340.              F2,
  341.              1,0,
  342.              Nil);
  343.  
  344.   ImF3:=Image(1,1,
  345.              48,
  346.              13,
  347.              1,
  348.              F3,
  349.              1,0,
  350.              Nil);
  351.  
  352.   ImF4:=Image(1,1,
  353.              48,
  354.              13,
  355.              1,
  356.              F4,
  357.              1,0,
  358.              Nil);
  359.  end;
  360.  
  361.  
  362. Function FindWhere : integer;
  363.  begin
  364.   Mx :=Win^.MouseX;
  365.   Mx :=Mx-25;        {bring it to...(50 div 2 = 25)}
  366.   My :=Win^.MouseY;
  367.   My :=My-6;             {...the center of the window.(13 div 2 = 6)}
  368.   if My<0 then add:=90
  369.    else add:=270;    {these additions are necessary to gain a 'Normal' angel}
  370.         {any body who wants to know more can print the Tan(Mx/My) for some
  371.                                                                    Mx and My}
  372.   if My=0 then My:=1; {avoid division by zero}
  373.  
  374.   x:=Mx/My;             {now w'll take the Tan(Mx/My) by the Taylor method}
  375.   if abs(x)<1 then
  376.    Ang:=x-x*x*x/3+x*x*x*x*x/5
  377.   else if x>=1 then
  378.    Ang:=3.14/2-1/x+1/(3*x*x*x)
  379.   else Ang:=-3.14/2-1/x+1/(3*x*x*x);
  380.  
  381.   Ang:=Ang*180/3.14; {convert it to degrees}
  382.   Ang :=Ang+add;
  383.  
  384.            {now we'll decide which image to show}
  385.   CurCoOrd := round(Mx + My);
  386.   if (abs(Mx)<12) and (abs(My)<9) then begin
  387.    FindWhere := 0;
  388.    exit;
  389.    end;
  390.  
  391.   if (Ang > 5) and (Ang < 175) then begin
  392.    if (Ang < 75) then begin
  393.     FindWhere := 1;
  394.     exit;
  395.     end;
  396.    if (Ang > 105) then begin
  397.     FindWhere := 2;
  398.     exit;
  399.     end;
  400.     FindWhere := 3;
  401.     exit;
  402.   end;
  403.  
  404.   if (Ang >175) and (Ang <185) then begin
  405.    FindWhere := 4;
  406.    exit;
  407.    end;
  408.   if (Ang > 185) and (Ang <255) then begin
  409.    FindWhere := 5;
  410.    exit;
  411.    end;
  412.   if (Ang >255) and (Ang <285) then begin
  413.    FindWhere := 6;
  414.    exit;
  415.    end;
  416.   if (Ang >285) and (Ang <355) then begin
  417.    FindWhere := 7;
  418.    exit;
  419.    end;
  420.   FindWhere := 8;
  421. end;
  422.  
  423. Procedure ShowImage;
  424.  begin
  425.   case CurImage of
  426.    0: DrawImage(Rast,^ImSquaint, 0, 0);
  427.    1: DrawImage(Rast, ^ImRU, 0, 0);
  428.    2: DrawImage(Rast,^ImLU, 0, 0);
  429.    3: DrawImage(Rast,^ImUp, 0, 0);
  430.    4: DrawImage(Rast,^ImLeft, 0, 0);
  431.    5: DrawImage(Rast,^ImLD, 0, 0);
  432.    6: DrawImage(Rast,^ImDown, 0, 0);
  433.    7: DrawImage(Rast,^ImRD, 0, 0);
  434.    8: DrawImage(Rast,^ImRight, 0, 0);
  435.   end;
  436. end;
  437.  
  438. Procedure Blink;
  439.  begin
  440.   DrawImage(Rast,^ImF1, 0, 0);
  441.   Delay(1);
  442.   DrawImage(Rast,^ImF2, 0, 0);
  443.   Delay(1);
  444.   DrawImage(Rast,^ImF3, 0, 0);
  445.   Delay(1);
  446.   DrawImage(Rast,^ImF4, 0, 0);
  447.   Delay(1);
  448.   DrawImage(Rast,^ImF1, 0, 0);
  449.   Delay(12);
  450.   DrawImage(Rast,^ImF4, 0, 0);
  451.   Delay(1);
  452.   DrawImage(Rast,^ImF3, 0, 0);
  453.   Delay(1);
  454.   DrawImage(Rast,^ImF2, 0, 0);
  455.   Delay(1);
  456.   DrawImage(Rast,^ImF1, 0, 0);
  457.   Delay(3);
  458.  end;
  459.  
  460. Procedure LeftRight;
  461.  begin
  462.   for count := 1 to 2 do begin
  463.    DrawImage(Rast,^ImStraight, 0, 0);
  464.    Delay(3);
  465.    DrawImage(Rast,^ImRight, 0, 0);
  466.    Delay(30);
  467.    DrawImage(Rast,^ImStraight, 0, 0);
  468.    Delay(6);
  469.    DrawImage(Rast,^ImLeft, 0, 0);
  470.    Delay(30);
  471.    DrawImage(Rast,^ImStraight, 0, 0);
  472.    Delay(3)
  473.   end;
  474. end;
  475.  
  476. Procedure GoToSleep;
  477.  Begin
  478.   DrawImage(Rast,^ImF1, 0, 0);
  479.   Delay(2);
  480.   DrawImage(Rast,^ImF2, 0, 0);
  481.   Delay(2);
  482.   DrawImage(Rast,^ImF3, 0, 0);
  483.   Delay(2);
  484.   DrawImage(Rast,^ImF4, 0, 0);
  485.   Delay(10);
  486. end;
  487.  
  488. Procedure Effect;
  489.  begin
  490.   SameImage := 0;
  491.   bool := WindowToFront(Win);
  492.   LeftRight;
  493.   GoToSleep;
  494.   CurImage := FindWhere;
  495.   while(CurCoOrd = PrevCoOrd) do begin
  496.    Delay(10);
  497.    CurImage := FindWhere;
  498.    Inc(SameImage);
  499.    if (SameImage = 150) then begin
  500.     LeftRight;
  501.     SameImage := 0;
  502.     ShowImage;
  503.     Delay(25);
  504.     GoToSleep;
  505.    end;
  506.   end;
  507.   DrawImage(Rast,^ImF3, 0, 0);
  508.   Delay(2);
  509.   DrawImage(Rast,^ImF2, 0, 0);
  510.   Delay(2);
  511.   DrawImage(Rast,^ImF1, 0, 0);
  512.   Delay(2);
  513. end;
  514.  
  515. Begin
  516.   PrevCoOrd := 0;
  517.   PRG:=Intuitext(1,0,0,0,0,Nil  ,'   FollowMouse',Nil);
  518.   Name:=Intuitext(1,0,0,0,10,Nil,'By Kamran Karimi',^PRG);
  519.  
  520.   { reserve memory: } { 2 = "MEMF_CHIP" }
  521.   Straight:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  522.   Squaint:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  523.   Up:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  524.   Down:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  525.   Left:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  526.   Right:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  527.   RU:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  528.   RD:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  529.   LU:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  530.   LD:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  531.   F1:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  532.   F2:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  533.   F3:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  534.   F4:=Ptr( Alloc_Mem(SizeOf(Plane), 2) );
  535.  
  536.   if(Squaint=nil) or (Up=Nil) or (Down=Nil) or (Right=Nil) or (Left=Nil)
  537.    or (LU=Nil) or (LD=Nil) or (RU=Nil) or (RD=Nil) or (F1=Nil)
  538.    or (F2=Nil) or (F3=Nil) or (F4=Nil) or (Straight=Nil)then goto EndIt;
  539.  
  540.   Initialize;
  541.  
  542.   Old:=SetTaskPri(FindTask(NIL),-2);
  543.   Randomize;
  544.   x1 := Random(400) + 80;
  545.   y1 := Random(140) + 20;
  546.   Wind:=NewWindow(x1,y1,150,35,0,1,0,WINDOWDRAG,
  547.                    Nil,Nil,'FollowMouse',Nil,Nil,0,0,0,0,WBENCHSCREEN);
  548.   Win:=OpenWindow(^Wind);
  549.   if (Win = Nil) then goto EndIt;
  550.   Rast:=Win^.RPort;
  551.   PrintItext(Rast,^Name,10,12);
  552.   Delay(150);
  553.   CloseWindow(Win);
  554.  
  555.   Wind:=NewWindow(x1,y1,50,13,0,0,MOUSEBUTTONS,WINDOWDRAG or RMBTRAP,
  556.                       Nil,Nil,'FM',Nil,Nil,0,0,0,0,WBENCHSCREEN);
  557.   Win:=OpenWindow(^Wind);
  558.   if (Win = Nil) then goto Endit;
  559.  
  560.   Rast:=Win^.RPort;
  561.  
  562.   while (True) do  {This is the main loop}
  563.   begin
  564.   Mes1 := Get_Msg(Win^.UserPort);
  565.   if(Mes1 <> Nil) then begin
  566.    Sec1 := Mes1^.Seconds;
  567.    Mic1 := Mes1^.Micros;
  568.   end;
  569.   Mes2 := Get_Msg(Win^.UserPort);
  570.   if(Mes2 <> Nil) then begin
  571.    Sec2 := Mes2^.Seconds;
  572.    Mic2 := Mes2^.Micros;
  573.   end;
  574.   if((Mes1 <> Nil) and (Mes2 <> Nil)) then begin
  575.    if(DoubleClick(Sec1,Mic1,Sec2,Mic2)) then begin
  576.     x1 := SetTaskPri(FindTask(NIL),Old);
  577.     goto EndIt;
  578.    end;
  579.   end;
  580.   if(Mes1 <> Nil) then Reply_Msg(Mes1);
  581.   if(Mes2 <> Nil) then Reply_Msg(Mes2);
  582.   CurImage := FindWhere;
  583.   ShowImage;
  584.   Delay(3);
  585.   if (CurCoOrd = PrevCoOrd) then Inc(SameImage)
  586.   else begin
  587.    PrevCoOrd := CurCoOrd;
  588.    SameImage := 0;
  589.   end;
  590.   if(SameImage = 180) then begin
  591.    Effect;
  592.    SameImage := 0;
  593.   end;
  594.   R := Random(40);
  595.   if R>38 then Blink;
  596.   end;
  597.  
  598. EndIt:
  599.  Reply_Msg(Mes1);
  600.  Reply_Msg(Mes2);
  601.  repeat
  602.   Mes1 := Get_Msg(Win^.UserPort);
  603.   if (Mes1 <> Nil) then Reply_Msg(Mes1);
  604.  until (Mes1 = Nil);
  605.  CloseWindow(Win); 
  606. End.
  607.  
  608.